package com.adtech.farmProducts.utils;

import android.os.Build;

import com.amap.api.location.AMapLocation;
import com.bumptech.glide.request.RequestOptions;
import com.adtech.farmProducts.R;

import java.util.UUID;

public class Constants {

    public static boolean cloudIsShow=false;

    //the descriptor of battery characteristic(battery service)00002902-0000-1000-8000-00805f9b34fb
    public static String CLIENT_CHARACTERISTIC_CONFIG = "00002902-0000-1000-8000-00805f9b34fb";

    public static AMapLocation location=null;
    /**
     * 是否听单
     */
    public static boolean isWork = false;

    public static int userType=2;//1、操作用户刷新token，2、游客刷新token


    /**
     * 是否重新连接
     */
    public static boolean isRelink = false;
    public static String driverWorkState = "1";//司机状态  0-未听单 1-听单 2-忙碌

    public static String TCP_IP = "";
    public static int TCP_PORT =20480;

    /**
     * 是否有经纬度
     *
     * @return AMapLocation
     */
    public static AMapLocation getLocation() {
        if (location != null && location.getProvince() != null && !"".equals(location.getProvince()) && location.getCity() != null && !"".equals(location.getCity())) {
            return location;
        }
        return null;
    }


    /**
     * 图片加载
     *
     * @return
     */
    public static RequestOptions getOptions() {
        return new RequestOptions()
                .placeholder(R.drawable.logo_transparency)//图片加载出来前，显示的图片
                .fallback(R.drawable.logo_transparency) //url为空的时候,显示的图片
                .error(R.drawable.logo_transparency);//图片加载失败后，显示的图片
    }

    public static String getUniquePsuedoID() {
        String serial;// 35是IMEI开头的号
        String m_szDevIDShort = "35" + Build.BOARD.length() % 10 + Build.BRAND.length() % 10 + Build.CPU_ABI.length() % 10 + Build.DEVICE.length() % 10 +
                Build.DISPLAY.length() % 10 + Build.HOST.length() % 10 + Build.ID.length() % 10 + Build.MANUFACTURER.length() % 10 +
                Build.MODEL.length() % 10 + Build.PRODUCT.length() % 10 +
                Build.TAGS.length() % 10 + Build.TYPE.length() % 10 + Build.USER.length() % 10; //13 位
        try {
            serial = android.os.Build.class.getField("SERIAL").get(null).toString(); //API>=9 使用serial号
            return new UUID(m_szDevIDShort.hashCode(), serial.hashCode()).toString();
        } catch (Exception exception) { //serial需要一个初始化
            serial = "ADT_ECH"; // 随便一个初始化
        }   //使用硬件信息拼凑出来的15位号码
        return new UUID(m_szDevIDShort.hashCode(), serial.hashCode()).toString();
    }
}
